package com.grj.park.test;


import org.flowable.engine.delegate.TaskListener;
import org.flowable.task.service.delegate.DelegateTask;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.stereotype.Component;


@Component
public class ParkingApplicationListener implements TaskListener {

    private static final Logger logger = LoggerFactory.getLogger(ParkingApplicationListener.class);


    @Override
    public void notify(DelegateTask delegateTask) {
        // 打印日志
        logger.info("停车申请任务已创建, 任务ID: {}", delegateTask.getId());

        // 设置任务的办理人
        String userId = (String) delegateTask.getVariable("userId");
        delegateTask.setAssignee(userId);

        sendNotificationEmail(userId, delegateTask.getId(), "申请已提交");



        // 设置其他任务变量
        delegateTask.setVariable("applicationStatus", "Pending");
    }

    public void sendNotificationEmail(String userId, String taskId, String message) {
        logger.info("停车申请状态更新，通知邮件已发送给用户: {}", userId);
    }

    public void sendRejectionEmail(String userId, String taskId) {
        sendNotificationEmail(userId, taskId, "您的停车申请未通过");
    }
}

